import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
const path = require("path");

export default defineConfig({
    plugins: [vue()],
    css: {
        preprocessorOptions: {
            less: {
                modifyVars: {
                    hack: `true; @import (reference) "${path.resolve("src/assets/static/css/common.less")}";`,
                },
                javascriptEnabled: true,
            },
        },
    },
    server: {
        port: "3000",
        open: false,
        base: "./",
        proxy: {
            "/apis": {
                target: "https://m.maoyan.com/",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/apis/, ""),
            },
        },
    },
    resolve: {
        alias: [
            {
                find: /^~/,
                replacement: "",
            },
            {
                find: "@",
                replacement: path.resolve(__dirname, "src"),
            },
            {
                find: "components",
                replacement: path.resolve(__dirname, "src/components"),
            },
            {
                find: "views",
                replacement: path.resolve(__dirname, "src/views"),
            },
            {
                find: "assets",
                replacement: path.resolve(__dirname, "src/assets"),
            },
            {
                find: "network",
                replacement: path.resolve(__dirname, "src/network"),
            },
            {
                find: "utils",
                replacement: path.resolve(__dirname, "src/utils"),
            },
            {
                find: "mitt",
                replacement: path.resolve(__dirname, "src/mitt"),
            },
        ],
    },
});
